# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
  def svs_checkboxes(model, field, values, current = nil)
    content = ""

    if current == nil
      current = ""
    end

    i = 0
    for value in values do
      options = {:id => model.to_s << "_" << field.to_s << i.to_s, :name => model.to_s << "[" << field.to_s << "][]", :checked => checked?(value, current)}
      name = model.to_s << "[" << field.to_s << "][]"
      #content << check_box(model, field, options, checked_value = value, unchecked_value = nil) << " " << value << "<br />\n"
      content << check_box_tag(name, value, checked?(value, current), {}) << " " << value << "<br />"
      i += 1
    end
    
    return content
  end
  
  def checked?(name, value)
    if value.index(name) != nil
      return true
  	else
      return false
  	end
  end
end
